package net.jlibrary.invoice.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.BatchSize;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.entity.BaseObject;
import net.jlibrary.curbparking.domain.ParkRecord;

@Entity(name = "tab_create_invoice")
//@SeePurview(value = "record.group.globalPath")
@BatchSize(size = 15)
@CodeGenComment(value = "开票信息", genSelect = false, add = false, update = false, delete = false)
public class ElectronicInvoiceKpInfo extends BaseObject {
	private static final long serialVersionUID = -6489938604216201964L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@SearchField(value = "id", condition = SearchCondition.EQUAL)
	private Long id;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "parkrecord_id")
	@SearchField(value = "record", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "订单", viewText = true, viewList = true, viewSearch = true, required = true)
	private ParkRecord record;// 订单，此处以后可以改为一对多，一张发票对于多笔订单

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "electronic_invoice_id")
	@SearchField(value = "eiSetting", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "销方信息")
	private ElectronicInvoice eiSetting;// 销方信息

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "electronic_incoicegf_id")
	@SearchField(value = "gfInfo", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "购方信息", viewList = false, viewSearch = true, required = true)
	private ElectronicInvoiceGfInfo gfInfo;// 购方信息

	@Column(length = 11)
	@CodeGenComment(value = "中税发票Id", viewList = true, required = true)
	private Long zsid;

	@Column(length = 12)
	@SearchField(value = "fpdm", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "发票代码", viewList = true, required = true)
	private String fpdm;
	@Column(length = 12)
	@SearchField(value = "yfpdm", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "原发票代码", viewList = true, required = true)
	private String yfpdm;// 红冲后的发票不为空

	@Column(length = 12)
	@SearchField(value = "yfphm", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "原发票号码", viewList = true, required = true)
	private String yfphm;// 红冲后的发票不为空

	@Column(length = 8)
	@SearchField(value = "fphm", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "发票号码", viewList = true, required = true)
	private String fphm;

	@Column(length = 112)
	@CodeGenComment(value = "税控码", viewList = true, required = true)
	private String skm;

	@CodeGenComment(value = "开票日期", viewList = true, required = true)
	private Date kprq;

	@Column(length = 22)
	@CodeGenComment(value = "校验码", viewList = true, required = true)
	private String jym;//

	@Column(length = 200)
	@CodeGenComment(value = "电子发票pdf格式文件", viewList = true, required = true)
	private String pdfUrl;

	@Column(length = 200)
	@CodeGenComment(value = "电子发票ofd格式文件", viewList = true, required = true)
	private String url;

	@Column(length = 30)
	@CodeGenComment(value = "开盘税控号 ", viewList = true, required = true)
	private String kpzdbs;

	@Column(length = 20)
	@CodeGenComment(value = "负数发票的税控码", viewList = true, required = true)
	private String negativeSkm;

	@Column(length = 20)
	@CodeGenComment(value = "负数发票的校验码", viewList = true, required = true)
	private String negativeJym;

	@Column(length = 20)
	@CodeGenComment(value = "作废日期", viewList = true, required = true)
	private Date negativeKprq;

	@Column(length = 20)
	@CodeGenComment(value = "请求税局的发票请求流水号", viewList = true, required = true)
	private String fpqqlsh;

	@Column(length = 8192)
	@CodeGenComment(value = "二维码", viewList = true, required = true)
	private String ewm;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "invoiceType_id")
	@CodeGenComment(value = "发票类型 ", viewList = true, required = true)
	private InvoiceType invoiceType;// 增值税电子发票 026 增值税专用发票 004 增值税普通发票 007 增值税电子专用发票 028

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "invoiceStatus_id")
	@CodeGenComment(value = "状态 ", viewList = true, required = true)
	private InvoiceStatus status;// 1待填写抬头 2开票完成 20开票中 22开票失败

	@Column(length = 130)
	@CodeGenComment(value = "备注 ", viewList = true, required = true)
	private String bz;

	@Column(length = 200)
	@CodeGenComment(value = "开票失败原因", viewList = true, required = true)
	private String errorMsg;

	@Column(updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "创建时间", viewList = true)
	private Date createdate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastdate;

	public Long getId() {
		return id;
	}

	public ParkRecord getRecord() {
		return record;
	}

	public void setRecord(ParkRecord record) {
		this.record = record;
	}

	public ElectronicInvoice getEiSetting() {
		return eiSetting;
	}

	public void setEiSetting(ElectronicInvoice eiSetting) {
		this.eiSetting = eiSetting;
	}

	public Long getZsid() {
		return zsid;
	}

	public void setZsid(Long zsid) {
		this.zsid = zsid;
	}

	public String getFpdm() {
		return fpdm;
	}

	public void setFpdm(String fpdm) {
		this.fpdm = fpdm;
	}

	public String getFphm() {
		return fphm;
	}

	public void setFphm(String fphm) {
		this.fphm = fphm;
	}

	public String getSkm() {
		return skm;
	}

	public void setSkm(String skm) {
		this.skm = skm;
	}

	public Date getKprq() {
		return kprq;
	}

	public void setKprq(Date kprq) {
		this.kprq = kprq;
	}

	public String getJym() {
		return jym;
	}

	public void setJym(String jym) {
		this.jym = jym;
	}

	public String getPdfUrl() {
		return pdfUrl;
	}

	public void setPdfUrl(String pdfUrl) {
		this.pdfUrl = pdfUrl;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getKpzdbs() {
		return kpzdbs;
	}

	public void setKpzdbs(String kpzdbs) {
		this.kpzdbs = kpzdbs;
	}

	public String getFpqqlsh() {
		return fpqqlsh;
	}

	public void setFpqqlsh(String fpqqlsh) {
		this.fpqqlsh = fpqqlsh;
	}

	public InvoiceType getInvoiceType() {
		return invoiceType;
	}

	public void setInvoiceType(InvoiceType invoiceType) {
		this.invoiceType = invoiceType;
	}

	public InvoiceStatus getStatus() {
		return status;
	}

	public void setStatus(InvoiceStatus status) {
		this.status = status;
	}

	public String getBz() {
		return bz;
	}

	public void setBz(String bz) {
		this.bz = bz;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public Serializable getPrimaryKey() {
		return id;
	}

	public ElectronicInvoiceGfInfo getGfInfo() {
		return gfInfo;
	}

	public void setGfInfo(ElectronicInvoiceGfInfo gfInfo) {
		this.gfInfo = gfInfo;
	}

	public Date getCreatedate() {
		return createdate;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}

	public Date getLastdate() {
		return lastdate;
	}

	public void setLastdate(Date lastdate) {
		this.lastdate = lastdate;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public String getEwm() {
		return ewm;
	}

	public void setEwm(String ewm) {
		this.ewm = ewm;
	}

	public String getNegativeSkm() {
		return negativeSkm;
	}

	public void setNegativeSkm(String negativeSkm) {
		this.negativeSkm = negativeSkm;
	}

	public String getNegativeJym() {
		return negativeJym;
	}

	public void setNegativeJym(String negativeJym) {
		this.negativeJym = negativeJym;
	}

	public Date getNegativeKprq() {
		return negativeKprq;
	}

	public void setNegativeKprq(Date negativeKprq) {
		this.negativeKprq = negativeKprq;
	}

	public String getYfpdm() {
		return yfpdm;
	}

	public void setYfpdm(String yfpdm) {
		this.yfpdm = yfpdm;
	}

	public String getYfphm() {
		return yfphm;
	}

	public void setYfphm(String yfphm) {
		this.yfphm = yfphm;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ElectronicInvoiceKpInfo other = (ElectronicInvoiceKpInfo) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}
